package com.dw.library.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;

/**
 * 
 */
public class RectIndicator extends AbsViewPagerIndicator {
  private static final String TAG = "RectIndicator";
  
  private Paint paintStroke;
  private Paint paint;
  private float strokeW;

  public RectIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    init();
  }

  public RectIndicator(Context context, AttributeSet attrs) {
    super(context, attrs);
    init();
  }

  public RectIndicator(Context context) {
    super(context);
    init();
  }
  
  private void init(){
    strokeW = 3;
    
    paint = new Paint();
    paint.setAntiAlias(true);
    paint.setColor(Color.BLUE);
    
    paintStroke = new Paint();
    paintStroke.setAntiAlias(true);
    paintStroke.setColor(Color.BLACK);
    paintStroke.setStyle(Paint.Style.STROKE);
    paintStroke.setStrokeWidth(strokeW);
  }

  @Override
  protected void drawBackground(Canvas canvas, float left, float top, float right, float bottom) {
    canvas.drawRect(left, top, right, bottom, paintStroke);
  }

  @Override
  protected void drawIndicator(Canvas canvas, float left, float top, float right, float bottom) {
    canvas.drawRect(left + strokeW, top + strokeW, right - strokeW, bottom - strokeW, paint);
  }
}
